// JavaScript Document
var error = "";
				var compName="";
				var compPhone="";
function validateForm2(strURL,formname,responsediv,responsemsg) {
				error = "";
				var _boolForm = 0;
				var emptyPreMessge = "You must include an accurate";
				var emptyPostMessge = "for a response";
				//var "Invalid E-mail ID" = "Invalid E-mail ID"

				
				compName=document.forms["frmShippers"]["txtCompanyName"].value;
				compPhone=document.forms["frmShippers"]["txtPhone"].value;

				
				
				//alert(cstSub);
				document.getElementById("status").innerHTML	= "";
				
				
				var nameError = "";
				if(compName == "" || compName == null)
				{
					document.forms["frmShippers"]["txtCompanyName"].focus();
					error = "Name must not be empty";
					document.getElementById("status").innerHTML	= error;
					//alert(error);	
					return false;	
				}
				else if(lengthRestriction(compName,3,25) == true)
				{
					
					if(isAlphabet(compName) == true)
					{
						_boolForm = 0;  // if valid bool setting to zero check other fields
					}
					else
					{
						document.forms["frmShippers"]["txtCompanyName"].focus();
						error = "Name must contain only letters";
						document.getElementById("status").innerHTML	= error;
						return false;
					}
				}
				else
				{
					document.forms["frmShippers"]["txtCompanyName"].focus();
					error = "Please enter the Name between " +3+ " and " +25+ " characters";
					document.getElementById("status").innerHTML	= error;
					return false;
				}
				
					
				if(compPhone == "" || compPhone == null)
				{
					document.forms["frmShippers"]["txtPhone"].focus();
					error = "Phone Number must not be empty";
					document.getElementById("status").innerHTML	= error;
					return false
				}
				else 
				{  if(phonelength(compPhone,8) == true)
						
					{_boolForm = 1;}
					else 
				{
					//alert("Error message cstEmail else cstPhone");
					error = "Please enter the Phone Number with your country code";
				  	return false;
				}
					
				}
				
				
				if(_boolForm == 1)
				{
			document.getElementById("frmShippers").submit();
			
			}
					
	
			else
			return false;
				
}

function getTinyFormQuerystring() {

   var qstr = "name="+compName+"&phone="+compPhone;
	alert(qstr);
    return qstr;

}

function updatepage(str,responsediv){

    document.getElementById(responsediv).innerHTML = str;

}


function updatepage(str,responsediv){
    document.getElementById(responsediv).innerHTML = str;
}


	
function lengthRestriction(str, min, max){
	//var uInput = elem.value;
	//alert("lent")
	if(str.length >= min && str.length <= max){
		return true;
	}else{
		//alert("Please enter between " +min+ " and " +max+ " characters");
		document.forms["frmShippers"]["txtCompanyName"].focus();
		error = "Please enter the Name between " +min+ " and " +max+ " characters";
		document.getElementById("status").innerHTML	= error;
		return false;
	}
}

function isAlphabet(str){
	var alphaExp = /^[a-zA-Z-_ .',]+$/;
	if(str.match(alphaExp)){
		return true;
	}else{
		//alert("name must contain only letters");
		document.forms["frmShippers"]["txtCompanyName"].focus();
		error = "Name must contain only letters";
		document.getElementById("status").innerHTML	= error;
		//elem.focus();
		return false;
	}
}

function phonelength(str,min){
	//var uInput = elem.value;
	if(str.length >= min){
		//alert(str.length);
		return true;
	}
	else{
		//alert("Please enter the phone number with your country code");
		document.forms["frmShippers"]["txtPhone"].focus();
		error = "Please enter the Phone Number with your country code";
		document.getElementById("status").innerHTML	= error;
		return false;
	}
}

function numbersonly(e) {
var unicode=e.charCode? e.charCode : e.keyCode;
//alert(unicode)
	if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
			if(unicode == 40 || unicode == 41) // () allowing
			{
				return true;
			}
			else if(unicode == 45 || unicode == 43) //45- && 43 + 
			{
				return true;
			}
			else if(unicode == 58 || unicode == 32) //58 :- && 32 space
			{
				return true;
			}
			else if(unicode == 37 || unicode == 39) //Delete
			{
				return true;
			}
			else if(unicode == 46 || unicode == 13) //Delete and enter
			{
				return true;
			}
			else if(unicode == 9) //tab
			{
				return true;
			}
			else if (unicode<48||unicode>57)
			{
			  document.getElementById("status").innerHTML	= "Please enter the numbers";
			  return false;//if not a number return false //disable key press
			}
		}
} 

// append image
//var img = document.createElement("img");
function show_image() {
    var img = document.createElement("IMG");
	//img.src = "Small Alert Icon.png";
    img.src = "Small Alert Icon.png";
   // img.width = width;
   // img.height = height;
    //img.alt = alt;

    // This next line will just add it to the <body> tag
    //document.body.appendChild(img);
	document.getElementById('status').appendChild(img);
}



